package com.taxx.config;

import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import java.util.Map;

/**
 * 税务报送配置
 */
@Data
@Configuration
@ConfigurationProperties(prefix = "tax.report")
public class TaxReportConfig {

    /**
     * 基础URL
     */
    private String baseUrl = "https://xxbs.lqpt.chinatax.gov.cn:8443/access/v2/invoke";

    /**
     * 能力编码
     */
    private String capabilityCode = "205001";

    /**
     * 服务编码
     */
    private String serviceCode = "SSXXBS";

    /**
     * 请求超时时间（毫秒）
     */
    private int timeout = 30000;

    /**
     * 重试次数
     */
    private int retryTimes = 3;

    private String platformId;

    private String platformSecret;

    /**
     * 业务类型配置
     */
    private Map<String, String> businessTypes;

    /**
     * 请求头配置
     */
    private Map<String, String> headers;

    private Map<String, String> config;

    /**
     * 获取完整的报送URL
     */
    public String getReportUrl() {
        return String.format("%s/%s/%s/", baseUrl, capabilityCode, serviceCode);
    }

    public String getReportUUIDUrl() {
        return String.format("%s/%s/%s/", baseUrl, capabilityCode,"CXPTUUID");
    }

    /**
     * 获取身份信息报送URL
     */
    public String getIdentityReportUrl() {
        return getReportUrl();
    }

    /**
     * 获取收入信息报送URL
     */
    public String getIncomeReportUrl() {
        return getReportUrl();
    }


    /**
     * 平台信息报送接口URL
     */
    public String getPlatformReportUrl() {
        return getReportUrl();
    }

    /**
     * 身份信息作废接口URL
     */
    public String getIdentityCancelUrl() {
        return getReportUrl();
    }

    /**
     * 收入信息作废接口URL
     */
    public String getIncomeCancelUrl() {
        return getReportUrl();
    }

    /**
     * 平台信息作废接口URL
     */
    public String getPlatformCancelUrl() {
        return getReportUrl();
    }

    public String getPtUuidUrl() {
        return getReportUUIDUrl();
    }


    /**
     * 获取身份信息报送业务类型
     */
    public String getIdentityBusinessType() {
        return businessTypes != null ? businessTypes.get("identity") : "PTXXBS01";
    }

    /**
     * 获取收入信息报送业务类型
     */
    public String getIncomeBusinessType() {
        return businessTypes != null ? businessTypes.get("income") : "PTXXBS02";
    }

    /**
     * 获取平台信息报送业务类型
     */
    public String getPlatformBusinessType() {
        return businessTypes != null ? businessTypes.get("platform") : "PTXXBS06";
    }

    /**
     * 获取身份信息作废业务类型
     */
    public String getIdentityCancelBusinessType() {
        return businessTypes != null ? businessTypes.get("identity-cancel") : "PTXXZF01";
    }

    /**
     * 获取收入信息作废业务类型
     */
    public String getIncomeCancelBusinessType() {
        return businessTypes != null ? businessTypes.get("income-cancel") : "PTXXZF02";
    }

    /**
     * 获取平台信息作废业务类型
     */
    public String getPlatformCancelBusinessType() {
        return businessTypes != null ? businessTypes.get("platform-cancel") : "PTXXZF03";
    }
}
